//导入封装的axios对象
import request from "@/utils/request2";
//导入自定义数据类型
import type { Admin, Category, CutpageParam, Goods, User } from "@/model";

//返回图片上传地址
export function uploadPictureURL() {
  return "/admin/upload/picture";
}

//管理员登录接口
export function login(data: Admin) {
  return request.post("/admin/login", data);
}

//获得当前登录管理员的信息
export function getAdmin() {
  return request.get("/admin/admin");
}

//获得分类列表
export function getCategoryList() {
  return request.get("/admin/category/list");
}

//添加分类
export function addCategory(data: Category) {
  return request.post("/admin/category/add", data);
}

//修改分类
export function updateCategory(data: Category) {
  return request.post("/admin/category/save", data);
}

//删除分类
export function delCategory(data: Category) {
  return request.post("/admin/category/del", data);
}

//查询所有商品
export function getGoodsList(params: CutpageParam) {
  return request.get("/admin/goods/list", { params });
}

//添加商品
export function addGoods(data: Goods) {
  return request.post("/admin/goods/add", data);
}

//修改商品
export function updateGoods(data: Goods) {
  return request.post("/admin/goods/save", data);
}

//删除商品
export function delGoods(data: Goods) {
  return request.post("/admin/goods/del", data);
}

//查询所有用户
export function getUserList() {
  return request.get("/admin/user/list");
}

//添加用户
export function addUser(data: User) {
  return request.post("/admin/user/add", data);
}

//修改用户状态
export function changeState(data: User) {
  return request.post("/admin/user/changeState", data);
}

//修改用户信息
export function updateUser(data: User) {
  return request.post("/admin/user/save", data);
}

//删除用户信息
export function deleteUser(data: User) {
  return request.post("/admin/user/delete", data);
}

//查询所有管理员
export function getAdminList() {
  return request.get("/admin/role/list");
}

//添加管理员
export function addAdmin(data: Admin) {
  return request.post("/admin/add", data);
}

//查询所有角色列表
export function getPermissionList() {
  return request.get("/admin/user/permission");
}

//修改管理员信息
export function updateAdmin(data: Admin) {
  return request.post("/admin/save", data);
}

//删除管理员信息
export function deleteAdmin(data: Admin) {
  return request.post("/admin/delete", data);
}

//修改管理员密码
export function changeAdminPassword(data: Admin) {
  return request.post("/admin/admin/changePassword", data);
}

//修改管理员头像
export function changeAdminAvatar(data: Admin) {
  return request.post("/admin/admin/changeAvatar", data);
}
